/-app
/-docs
/-files ...
FileTree.ts
FileTree2.ts
SyncStorageAccess.ts
/-imports
/-persistence
/-storage
/-typings
errors.js
functions.ts
index.html
try.js
x
 
22
      parentPath: string,
23
      public li: HTMLElement) {
24
​
25
      var childLIs: HTMLLIElement[] = [];
26
      for (var i = 0; i < this.li.children.length; i++) {
27
​
28
        var child = this.li.children[i];
29
        if ((<HTMLLIElement>child).tagName === 'LI') childLIs.push(<HTMLLIElement>child);
30
​
31
        if ((<HTMLDivElement>child).tagName === 'DIV' && (<HTMLDivElement>child).className) {
32
          if ((<HTMLDivElement>child).className.indexOf('teapo-file-name') >= 0) {
33
            this.isDir = false;
34
            this.name = child.textContent || (<HTMLDivElement>child).innerText;
35
          }
36
          else if ((<HTMLDivElement>child).className.indexOf('teapo-dir-name') >= 0) {
37
            this.isDir = true;
38
            this.name = child.textContent || (<HTMLDivElement>child).innerText;
39
          }
40
        }
41
​
42
        if ((<HTMLPreElement>child).tagName === 'PRE' && (<HTMLPreElement>child).className 
43
          && (<HTMLPreElement>child).className.indexOf('teapo-file-content') >= 0) {
44
          
45
          if (this._contentPRE) {
46
            // double content?
47
          }
48
          else {
49
            this._contentPRE = <HTMLPreElement>child;
50
          }
51
          
52
        }
53
​
54
      }
55
      
56
      this.fullPath = parentPath + '/' + this.name;
57
      
58
​
59
      this._createChildNodesAndSort(childLIs);
60
​
61
    }
62
​
63
​
64
    private _createChildNodesAndSort(childLIs: HTMLLIElement[]) {
65
      
66
      for (var i = 0; i < childLIs.length; i++) {
67
        var node = new Node(this.fullPath, childLIs[i]);
68
        
69
        if (node.isDir) {
70
          this._insertChildNode(this._subDirs, node, <any>this._files.length);
71
        }
72
        else {
73
          this._insertChildNode(this._subDirs, node, false);
74
        }
75
      }
76
      
77
    }
78
​
79
    private _insertChildNode(nodeList: Node[], nodeNode, forceRerootingEvenIfOrdered: boolean) {
80
      // TODO: binary search
81
    }
82
    
83
  }
84
  
85
}
79:15